import React, {Component} from 'react';
class TakeComment extends Component {
    content = React.createRef()
    //添加评论
    add = async (e)=>{
        if(e.keyCode===13){
            const value = this.content.current.value.trim()
            if(!value){
                window.alert('输入内容不能为空~')
            }else{
                await this.$http.post('/weibo',{content:value})
                this.content.current.value = ''
                this.props.getCommon()
            }
        }
    }
  render() {
    return (
        <div className="takeComment">
            <textarea onKeyUp={this.add} ref={this.content} name="textarea" className="takeTextField" id="tijiaoText"></textarea>
            <div className="takeSbmComment">
                <input onClick={this.add} type="button" className="inputs" value=""/>
            </div>
        </div>
    )
  }
}
export default TakeComment